import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/basic_information/scheduling_plan_entity.dart';
import 'package:get/get.dart';

class DutyRecordsDetailsController extends GetxController {
  String id = Get.arguments as String;

  /// 数据实体
  SchedulingPlanEntity planEntity = SchedulingPlanEntity();

  @override
  void onInit() {
    super.onInit();
    getDetailsData();
  }

  /// 获取详情数据
  void getDetailsData() async {
    // 获取详情接口
    final res = await HttpUtil().generateGetRequest<SchedulingPlanEntity>(
      Interface.getSchedulingConfigPlanRecord,
      queryParameters: {'id': id},
    ).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        planEntity = result.data!;
      }
      phoneList = [];
      if (planEntity.onDutyLeaderTel.isNotEmpty) {
        phoneList.add(planEntity.onDutyLeaderTel);
      }
      if (planEntity.onDutyUserPhone.isNotEmpty) {
        phoneList.add(planEntity.onDutyUserPhone);
      }
      update();
    });
  }

  /// 电话号码
  List<String> phoneList = [];
}
